#ifndef _LOGGING_H
#define _LOGGING_H

#include "AsyncLogging.h"
#include "LogStream.h"
#include <iostream>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>

namespace droneswarm
{
    //定义一个Logger类,这个类对日志系统的对外接口。
    class Logger
    {
    public:
        Logger( const char *fileName, int line );
        ~Logger();
        LogStream &stream() { return impl_.stream_; }
        static void setLogFileName( std::string fileName ) { logFileName_ = fileName; }
        static std::string getLogFileName() { return logFileName_; }

    private:
        class Impl
        {
        public:
            Impl( const char *fileName, int line );
            void formatTime();
            LogStream stream_;
            int line_;
            std::string basename_;
        };
        Impl impl_;
        static std::string logFileName_;
    };

#define LOG Logger( __FILE__, __LINE__ ).stream()  //定义log宏，用于输出日志信息

}  // namespace droneswarm

#endif